# Extract the version string from nmap.h.
# 获取最新打tag版本的commit id
#TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
# 获取当前分支最新commit id
#TAG_COMMIT := $(shell git rev-parse --short HEAD)
## `2>/dev/null` suppress errors and `|| true` suppress the error codes.
#TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
## here we strip the version prefix
#export VERSION := $(TAG:v%=%)-$(TAG_COMMIT)
# $(warning VERSION is $(VERSION))

#VERSION=$(shell cat VERSION | tr -d "\n" | tr -d ' ')
SERVER_MAIN_PKG=./cmd/application.go
SERVERBIN=safe-app-center
ENVIROMENT=netgo
GOOS=linux
GO_SERVER_BUILD_RECIPE=CGO_ENABLED=0 GOOS=$(GOOS) go build -tags $(ENVIROMENT) -a -ldflags '-s -w -extldflags "-static"' -o $(SERVERBIN) $(SERVER_MAIN_PKG)
REGISTRY=192.168.2.210:50000
PROJECT=asset

build:
	$(GO_SERVER_BUILD_RECIPE)
	upx -9 $(SERVERBIN)
#container:
#	docker build -t $(REGISTRY)/$(PROJECT)/$(SERVERBIN):$(VERSION) .
#push:
#	docker push $(REGISTRY)/$(PROJECT)/$(SERVERBIN):$(VERSION)
#test:
#	docker tag $(REGISTRY)/$(PROJECT)/$(SERVERBIN):$(VERSION) $(REGISTRY)/$(PROJECT)/$(SERVERBIN)-test:$(VERSION);docker save $(REGISTRY)/$(PROJECT)/$(SERVERBIN)-test:$(VERSION) > $(SERVERBIN)-test.tar;scp $(SERVERBIN)-test.tar root@cxxhome:.
#deploy:
#	kubectl delete pods -n traffic -l app=$(SERVERBIN)
#all: build container push
#.PHONY: build-server build-server-container push-container test

run:
	   go run ./cmd/application.go    --redisStr 127.0.0.1:6379   --redisPassword   GTS0je4P65vy+Kt88ZOaZZCwLEu1wDhS7b0dLef0TkI=   --dbUsername  postgres --dbPassword  GTS0je4P65vy+Kt88ZOaZQdyx+avipL7tx3UCU5G/5s=   --dbHost 127.0.0.1 --dbDatabase  safe_mgr --safeAppCenterUrl   0.0.0.0:19093  --reportUrl traffic-report-service.traffic.svc.cluster.local:9093
		exit 0
no:
	nohup go run ./cmd/application.go --redisStr 127.0.0.1:6379   --redisPassword   GTS0je4P65vy+Kt88ZOaZZCwLEu1wDhS7b0dLef0TkI=   --dbUsername  postgres --dbPassword  GTS0je4P65vy+Kt88ZOaZQdyx+avipL7tx3UCU5G/5s=   --dbHost 127.0.0.1 --dbDatabase  safe_mgr --safeAppCenterUrl   0.0.0.0:19093  --reportUrl traffic-report-service.traffic.svc.cluster.local:9093 &